<%@ page import="java.util.List" %>
<%@ page import="com.foreknow.model.GuestBook" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/8/23
  Time: 10:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--引用标签库 taglib--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="pager" uri="http://blog.zjjlive.net/zjjlive/tags/pager" %>
<html>
<head>
    <title>Title</title>

    <!-- Bootstrap core CSS -->
    <link href="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.12/dist/css/bootstrap.min.css"
          rel="stylesheet">

</head>
<body>
<div class="container" style="margin-top: 5px;">
        <h5 style="float: left;padding-top: 5px;">用户名：${sessionScope.username}</h5>
        <a href="/elm/AddMessage.html" class="btn btn-primary" style="float: right;margin-right: 9%;margin-bottom: 5px;">添加</a>
    <table class="table table-hover">
        <tr>
            <td style="width: 60px;">编号</td>
            <td>姓名</td>
            <td>电话</td>
            <td>邮箱</td>
            <td>标题</td>
            <td style="width: 250px;">内容</td>
            <td style="width: 100px;">创建时间</td>
            <td style="width: 220px;">操作</td>
        </tr>
        <%--        <%--%>
        <%--            //要从request对象获取到list集合--%>
        <%--            List<Object> list = (List<Object>) request.getAttribute("list");--%>
        <%--            for (int i = 0;i<list.size();i++)--%>
        <%--            {--%>
        <%--                GuestBook gb = (GuestBook) list.get(i);--%>

        <%--        %>--%>
        <c:forEach var="gb" items="${sessionScope.list}">
            <tr>
                <td>${gb.id}</td>
                <td>${gb.name}</td>
                <td>${gb.phone}</td>
                <td>${gb.email}</td>
                <td>${gb.title}</td>
                <td>${gb.content}</td>
                <td>${gb.createdTime}</td>
                <td>
                        <%--所有从客户端发送的请求都要经过Controller--%>
                    <a href="/elm/ManagerServlet?id=${gb.id}&q=update" class="btn btn-primary">修改</a>
                    <a href="/elm/ManagerServlet?id=${gb.id}&q=delete" class="btn btn-danger">删除</a>
                </td>
            </tr>
        </c:forEach>
        <%--        <%--%>
        <%--            }--%>
        <%--        %>--%>
    </table>
    <div>
        <pager:pager pageNo="${requestScope.pageNo}"
                     recordCount="${sessionScope.total}"
                     pageSize="${initParam.pageSize}"
                     url="/elm/ManagerServlet?q=list"/>
    </div>
</div>
</body>
</html>
